package edu.whu.puppygo.dao;

import edu.whu.puppygo.entity.Conversation;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ConversationDao extends JpaRepository<Conversation, Long>, JpaSpecificationExecutor<Conversation> {
    @Query("select c from Conversation c where c.userId = ?1")
    List<Conversation> findByUserId(long userId, Pageable pageable);

    @Query("select count(c) from Conversation c where c.userId = ?1")
    long countByUserId(long userId);
}